package com.hejjon.pojo;

import com.hejjon.core.domain.entity.Connection;
import com.hejjon.enumer.DriverEnum;

/**
 * @author: cs
 * @date: 2025-02-21 17:30:34
 * @since: 1.0
 */
public class ConnectionInfo {


    private String username;

    private String password;

    private String driver;

    private String url;

    public ConnectionInfo() {
    }

    public ConnectionInfo(Connection conn) {
        this.username = conn.getUsername();
        this.password = conn.getPassword();
        this.url = conn.getUrl();
        this.setDriver(conn.getDriveType());
    }


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driveType) {
        DriverEnum driverEnum = DriverEnum.getInstance(driveType);
        if (driverEnum != null)
        {
            this.driver = driverEnum.getDriver();
        } else {
            this.driver = DriverEnum.MYSQL.getDriver();
        }
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
